﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using XiaoMan.BLL;
using XiaoMan.Model.Models;
using XiaoMan.Service;

namespace XiaoMan.API.Controllers
{
    [RoutePrefix("api/relation")]
    public class RelationController : ApiBaseController
    {
        Sys_RelationService srs = new Sys_RelationService();

        /// <summary>
        /// 根据用户ID查询关注的人
        /// </summary>
        /// <returns></returns>
        [Route("getrelation")]
        [HttpGet]
        public IHttpActionResult getRelation(int? pageindex)
        {
            int userid = Convert.ToInt32(Request.Headers.GetValues("userid").FirstOrDefault());
            //拿到所有关注的人ID
            List<Sys_Relation> relations = srs.GetRelationByUser(userid, pageindex.Value);
            return ApiSuccess(relations);
        }
    }
}